﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using _MetalSlug.Form.ScreenSystem;
using _MetalSlug.Form.ScreenSystem.Message;

namespace _MetalSlug.Form
{
    public abstract class MyScreen : VisibleGameEntity
    {
        GameManager manager;
        public GameManager Manager
        {
            get { return manager; }
            set { manager = value; }
        }

        protected Texture2D background;
        public Texture2D Background
        {
            get { return background; }
            set { background = value; }
        }

        protected Boolean isOpened;
        public Boolean IsOpened
        {
            get { return isOpened; }
            set { isOpened = value; }
        }

        public enum TYPE
        {
            MAINMENU,
            LOADING,
            SETTING,
            SELECTCHAR,
            PLAYGAME,
            GAMEOVER,
            EXIT
        }

        protected TYPE typeOfWindow;
        public TYPE TypeOfWindow
        {
            get { return typeOfWindow; }
            set { typeOfWindow = value; }
        }

        virtual public void LoadContent()
        {
        }

        virtual public void HandleKeyboard()
        {
        }

        public override void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(Background, new Rectangle(0, 0, (int)GameUtil.ScreenSize.X, (int)GameUtil.ScreenSize.Y), Color.White);
        }

        public virtual void InitialAttribute()
        {
        }

        public virtual void Reset()
        {
            InitialAttribute();
        }

        public virtual void Send(MyScreen.TYPE TypeScreenReceive, MyMessage.TYPE TypeMessage, object MessageContent)
        {
            MyMessage SendMessage = null;
            switch(TypeMessage)
            {
                case MyMessage.TYPE.SHOW:
                    SendMessage = new ShowMessage(MessageContent);
                    break;

                case MyMessage.TYPE.LOADING:
                    SendMessage = new LoadingMessage(MessageContent);
                    break;
            }

            Manager.Receive(this, TypeScreenReceive, SendMessage);
        }

        public virtual void Receive(MyScreen SendWindow, MyMessage SendMessage)
        {
            SendMessage.Process(SendWindow, this);
        }
    }
}
